define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var controller = {
        index: function () {
            //初始化
            Table.api.init();
            this.table.first();
            this.table.sencond();
        },

        table: {
            first: function () {
                var table1 = $("#table1");
                table1.bootstrapTable({
                    url: 'test/tablelink/table1',
                    pk: 'id',
                    sortName: 'id',
                    toolbar :  '#toolbar1',
                    search:false,
                    columns: [
                        [
                            {checkbox: true},
                            {
                                field: 'id',
                                title: __('Id'),
                            },
                            {
                                field: 'username',
                                title: __('Username'),
                            },
                            {
                                field: 'operate',
                                title: __('Operate'),
                                width: "150px",
                                table: table1,
                                events: Table.api.events.operate,
                                formatter: Table.api.formatter.operate,
                                buttons: [
                                    {
                                        name: 'click',
                                        title: '日志列表',
                                        text: '日志列表',
                                        classname: 'btn btn-xs btn-info btn-click',
                                        icon: 'fa fa-list',
                                        click: function (e, data) {
                                            $("#myTabContent2 .form-commonsearch input[name='username']").val(data.username);
                                            $("#myTabContent2 .btn-refresh").trigger("click");

                                        }
                                    },
                                ]
                            }
                        ]
                    ]
                });
                Table.api.bindevent(table1);
            },
            sencond: function () {
                var table2 = $("#table2");
                table2.bootstrapTable({
                    url: 'test/tablelink/table2',
                    pk: 'id',
                    sortName: 'id',
                    toolbar :  '#toolbar2',
                    searchFormVisible: true,
                    search:false,
                    columns: [
                        [
                            {checkbox: true},
                            {
                                field: 'id',
                                title: __('Id'),
                            },
                            {
                                field: 'username',
                                title: __('Username'),
                            },
                            {
                                field: 'url',
                                title: __('Url')
                            },
                        ]
                    ]
                });
                Table.api.bindevent(table2);
            },
        },

    };
    return controller;
});